package com.cropdoctor.config;

import com.cropdoctor.model.constants.SearchConstants;
import io.redisearch.client.Client;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class RedisSearchConfig {

    @Value("${spring.redis.host}")
    String host;
    @Value("${spring.redis.port}")
    int port;
    int timeout = 3000;
    int poolSize = 10;

    @Bean(SearchConstants.POST_REDIS_SEARCH)
    public Client postSearchClient() {
        return new Client(SearchConstants.POST,host, port, timeout,poolSize);
    }

    @Bean(SearchConstants.TABLE_REDIS_SEARCH)
    public Client tableSearchClient() {
        return new Client(SearchConstants.TABLE,host, port, timeout,poolSize);
    }

    @Bean(SearchConstants.COURSE_REDIS_SEARCH)
    public Client courseSearchClient() {
        return new Client(SearchConstants.COURSE,host, port, timeout,poolSize);
    }
}
